package rad.framework.mda.generator.template.maven;

import org.eclipse.uml2.uml.Model;
import rad.framework.mda.generator.util.*;

public class PomWar
{
  protected static String nl;
  public static synchronized PomWar create(String lineSeparator)
  {
    nl = lineSeparator;
    PomWar result = new PomWar();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL + "<project>" + NL + "\t<parent>" + NL + "\t\t<groupId>";
  protected final String TEXT_2 = "</groupId>" + NL + "\t\t<artifactId>";
  protected final String TEXT_3 = "</artifactId>" + NL + "\t\t<version>";
  protected final String TEXT_4 = "</version>" + NL + "\t</parent>" + NL + "\t<modelVersion>4.0.0</modelVersion>" + NL + "\t<artifactId>";
  protected final String TEXT_5 = "</artifactId>" + NL + "\t<packaging>war</packaging>" + NL + "\t<name>";
  protected final String TEXT_6 = "</name>" + NL + "\t<description>WAR project for ";
  protected final String TEXT_7 = "</description>" + NL + "" + NL + "\t<dependencies>" + NL + "\t\t<dependency>" + NL + "\t\t\t<groupId>rad-framework</groupId>" + NL + "\t\t\t<artifactId>rad-framework-portal-web</artifactId>" + NL + "\t\t\t<version>${rad-framework.version}</version>" + NL + "\t\t\t<type>war</type>" + NL + "\t\t\t<scope>runtime</scope>" + NL + "\t\t</dependency>" + NL + "\t</dependencies>" + NL + "\t" + NL + "</project>";
  protected final String TEXT_8 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    Model uml2Model = (Model) argument;
    stringBuffer.append(TEXT_1);
    stringBuffer.append(MavenHelper.getGroupId(uml2Model));
    stringBuffer.append(TEXT_2);
    stringBuffer.append(MavenHelper.getArtifactId(uml2Model, "master"));
    stringBuffer.append(TEXT_3);
    stringBuffer.append(MavenHelper.getVersion(uml2Model));
    stringBuffer.append(TEXT_4);
    stringBuffer.append(MavenHelper.getArtifactId(uml2Model, "web"));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(MavenHelper.getName(uml2Model, "WAR"));
    stringBuffer.append(TEXT_6);
    stringBuffer.append(uml2Model.getName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(TEXT_8);
    return stringBuffer.toString();
  }
}
